package www.dianbaozu.com.ui.server

import androidx.hilt.lifecycle.ViewModelInject
import com.chad.library.adapter.base.entity.node.BaseNode
import www.wen.com.common.lib.base.module.BaseAbsViewModel
import www.wen.com.common.lib.data.entities.Result
import www.wen.com.common.lib.data.entities.ServerGroupEntity
import www.wen.com.common.lib.data.repository.AppDataManager


/**
 * @author WEN
 * @Description:创建新的服务器
 * @date 2020//25 17:48
 */
class ServerListViewModel @ViewModelInject constructor(appDataManager: AppDataManager) :
    BaseAbsViewModel<ServerGroupEntity, BaseNode>(appDataManager) {

    override val mIsUseTitleLoading = true

    override val mIsUseTitleError = true

    override val mLimit: Int
        get() = 70

    var mOwnUserId: String = ""

    override suspend fun requestListData(requiredParameter: Any): Result<ServerGroupEntity> =
        appDataManager.requestServerGroupList(requiredParameter as String)

    override fun dataConversion(data: ServerGroupEntity): List<BaseNode> {
        data.content.forEach {
            it.isExpanded = true
            it.ownUserId = mOwnUserId
        }
        return data.content
    }

}


